<?php

/*
 * Sistema:
 *
 * Página: layout (public/helpers/php)
 *
 * Histórico:
 *		v. 11/11/2012, EDGARD FANTINI JÚNIOR - efantinij@gmail.com
 *			- versão inicial
 *
 * FRAMWORK: edframe - Copyleft (cc) 2012 EDMAR Sistemas
 */

@session_start() ;

$time = time() + 3620 ;

require_once $_SESSION['dirName'].'/public/helpers/php/Sajax.php'  ;

require_once $_SESSION['dirApplication'].'/config/application.ini' ;

require_once $_SESSION['dirName'].'/public/helpers/php/objGeral.php' ;

if (file_exists($_SESSION['dirName'].$_SESSION['carregar'].".php"))
	require_once $_SESSION['dirName'].$_SESSION['carregar'].".php" ;

else
{
	echo "script ".$_SESSION['dirName'].$_SESSION['carregar'].".php n&atilde;o existe" ;
	echo "<br><A href='../../../index.php'>index</A>" ;
	@r();
}

try
{
	TTransaction::open($_SESSION['infoCon']);
	TTransaction::setLogger(new TLoggerTXT('/tmp/objGeral_verficaFuncao.txt'));

	$func = new sfuncao;
	$func->codigo = $segura ;
	$func->ativo = 'A' ;
	$func->colunas = "func" ;
	$_Func = $func->sfuncao ;

	if (empty($_Func))
		throw new Exception("Função solicitada está desativada (veja código ".$segura.")") ;

	$uf = new suserfun ;
	$uf->usuario = $_SESSION['userId'] ;
	$uf->func = $_Func[0]->func;
	$uf->ativo = 'A' ;
	$uf->colunas = "func" ;
	$_UserFun = $uf->suserfun ;

	if (empty($_UserFun))
		throw new Exception("Usuário não tem acesso à Função ".$segura) ;

	$_SESSION['tela'] = $_Func[0]->func ;
}
catch (Exception $e)
{
	$_var = MformTryCache::objReturnGet($e) ;
	$script = "
		<script>
			window.location='../../../index2.php?msgErro=".$_var."';
		</script>
	";
	print $script;
	@r();
}

if (!$_POST['nomeDaPagina'])
	$_POST['nomeDaPagina'] = $_POST['parametro1'] ;

$complementar = "../../..".str_replace("/controllers/","/js/",$_POST['nomeDaPagina'], $count).".js" ;
if ($count ==0)
	$complementar = "../../..".str_replace("/php/","/js/",$_POST['nomeDaPagina']).".js" ;

?>
<HTML>
	<HEAD>
		<?php
			if (file_exists($complementar))
			{
				?>
				<SCRIPT charset="utf-8" src="<?=$complementar?>"></SCRIPT>
				<?php
			}
			if ($carregJs)
			{
				foreach (explode("|",$carregJs) as $carrega)
				{
					?>
					<SCRIPT charset="utf-8" src="../js/<?=$carrega?>.js"></SCRIPT>
					<?php
				}
			}
		?>


		<SCRIPT charset="utf-8" src="../js/objGeral.js"></SCRIPT>
		<SCRIPT charset="utf-8" src="../js/jquery.js"></SCRIPT>
		<SCRIPT>
			<?
			sajax_show_javascript();
			?>
		</SCRIPT>

		<META http-equiv="cache-control"   content="no-cache" />
		<META http-equiv="pragma" content="no-cache" />
		<META http-equiv="expires" content = "0" />
		<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<TITLE><?= $_SESSION['nomeAplicacao'] ?></TITLE>
		<LINK rel="SHORTCUT ICON" href="../..<? echo $logo; ?>" />
		<LINK media="screen" href="../../css/edjoo.css" rel="stylesheet" type="text/css" />
		<LINK media="screen" href="../../css/caixaserro.css" rel="stylesheet" type="text/css" />
		<LINK media="print" href="../../css/edjooPrint.css" rel="stylesheet" type="text/css" />

		</HEAD>
		<BODY onload='acao(0);' >
			<FORM enctype='multipart/form-data' name='formu' method='POST' id='bodi' >
				<DIV class="logo">
					<TABLE class="entrada">
						<TR>
							<TD width ="12%" ><?= $_SESSION['nomeTela'] ?></TD>
							<TD width ="8%" ><?= date("d/m/Y", time()) ?></TD>
							<TD width ="8%" ><?= $_SESSION['nomeAplicacao'] ?></TD>
							<TD><BUTTON name='menu' onclick='retornar();'><FONT color='Red'>MENU PRINCIPAL</FONT></BUTTON></TD>
							<TD><BUTTON name='resset' onclick='sair();'><FONT color='Red'>SAIR</FONT></BUTTON></TD>
							<TD><DIV id ='relogio'></DIV></TD>
							<td align="right" width ="12%"></td>
							<td width ="12%"><div id ='contsessao'></div></td>

						</TR>
					</TABLE>
					<TABLE class="entrada">
						<TR id="alertaSessao" style ="display:none;  background-color: red; width: 100%;" align ="center">
							<TD style ="color: white; font-size: 2.0em;">Sua Sessão irá expirar em 1 minuto!!!</TD>
						</TR>
					</TABLE>
				</DIV>

				<DIV id='panel'>
					<DIV id='cen'>
						<DIV id='DivNomeDaPagina'></DIV>
						<DIV id='alertas'></DIV>
						<DIV id="alertasPop" class="branco">
							<TABLE>
								<TR>
									<TD id = 'cabecalhoAlerta' width = '100%' ></TD><TD id = 'fechaDivs'></TD>
								</TR>
								<TR>
									<TD colspan = '2' id = 'alertaContent'></TD>
								</TR>
								<TR>
									<TD colspan = '2' id = 'alertaBotoes'></TD>
								</TR>
							</TABLE>
						</DIV>
						<DIV id="geral" ></DIV>
						<DIV id="geral2"></DIV>
						<DIV id="geral3"></DIV>
						<DIV id="botoes" ></DIV>
					</DIV>
					<DIV id='esq'>
						<DIV id="esq1"></DIV>
						<DIV id="esq2"></DIV>
					</DIV>
					<DIV id='dir'>
						<DIV id="dir1"></DIV>
						<DIV id="dir2"></DIV>
						<DIV id="dir3">Copyleft (cc) 2011 EDMAR Sistemas</DIV>
					</DIV>
				</DIV>
				<DIV id="caixaMSG" ></DIV>

				<DIV id = 'caixaHiddens'>
					<INPUT type="hidden" name="txEsq1" value="<?= isset($esq1) ? $esq1 : '' ?>" />
					<INPUT type="hidden" name="txEsq2" value="<?= isset($_SESSION['menu']) ? $_SESSION['menu'] : '' ?>" />
					<INPUT type="hidden" name="caixaAlertaFlu" value="<?= isset($caixaAlertaFlu) ? $caixaAlertaFlu : '' ?>" />

					<INPUT type="hidden" name="caixaGeral"    value="<?= isset($caixaGeral) ? $caixaGeral : '' ?>" />
					<INPUT type="hidden" name="caixaGeral2"    value="<?= isset($caixaGeral2) ? $caixaGeral2 : '' ?>" />
					<INPUT type="hidden" name="caixaGeral3"    value="<?= isset($caixaGeral3) ? $caixaGeral3 : '' ?>" />
					<INPUT type="hidden" name="caixaBotoes"   value="<?= isset($caixaBotoes) ? $caixaBotoes : '' ?>" />
					<INPUT type="hidden" name="txDir1" value="<?= isset($dir1) ? $dir1 : '' ?>" />
					<INPUT type="hidden" name="txDir2" value="<?= isset($dir2) ? $dir2 : '' ?>" />
					<INPUT type="hidden" name="msgErro"       value="<?= isset($msgErro) ? $msgErro : '' ?>" />
					<INPUT type="hidden" name="msgSucesso"    value="<?= isset($msgSucesso) ? $msgSucesso : '' ?>" />
					<INPUT type='hidden' name="controle"      value="<?= isset($controle) ? $controle : '' ?>" />
					<INPUT type='hidden' name="audi"          value="<?= isset($audi) ? $audi : '' ?>" />
					<INPUT type='hidden' name="time"          value="<?= isset($time) ? $time : '' ?>" />
					<INPUT type='hidden' name="descricao" value="<?= isset($descricao) ? $descricao : '' ?>" />
					<INPUT type='hidden' name="nomeDaPagina" value="<?= $_POST['nomeDaPagina']  ?>" />
				</DIV>
				<?php
				if (!empty($hiddens))
					$hiddens->exibeHiddens();
				?>
			</FORM>
		</BODY>
	</HTML>
